package org.railage.server.entities;

import java.io.Serializable;
import java.sql.Timestamp;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;

import org.hibernate.annotations.NamedNativeQuery;
import org.railage.common.dto.ScheduleRecordDTO;

/**
 * Schedule record entity
 * 
 * @author Cyril Fertikov
 * 
 */
@NamedNativeQuery(
		name = "getSchedule", 
		query = "call proc_get_station_schedule(:station_name)", 
		resultClass = ScheduleRecord.class
)
@Entity
public class ScheduleRecord implements Serializable {

	private static final long serialVersionUID = -7988632674887221517L;

	@Id
	@Column(name = "trip_id")
	private int trip;

	@Column(name = "route_name")
	private String route;

	@Column(name = "arrival")
	private Timestamp arrival;

	@Column(name = "departure")
	private Timestamp departure;

	public ScheduleRecord() {

	}

	public int getTrip() {
		return trip;
	}

	public void setTrip(int trip) {
		this.trip = trip;
	}

	public String getRoute() {
		return route;
	}

	public void setRoute(String route) {
		this.route = route;
	}

	public Timestamp getArrival() {
		return arrival;
	}

	public void setArrival(Timestamp arrival) {
		this.arrival = arrival;
	}

	public Timestamp getDeparture() {
		return departure;
	}

	public void setDeparture(Timestamp departure) {
		this.departure = departure;
	}

	public ScheduleRecordDTO toDTO() {
		ScheduleRecordDTO dto = new ScheduleRecordDTO();
		dto.setTrip(trip);
		dto.setRoute(route);
		dto.setArrival(arrival);
		dto.setDeparture(departure);
		return dto;
	}

	@Override
	public String toString() {
		return "ScheduleRecord [trip=" + trip + ", route=" + route
				+ ", arrival=" + arrival + ", departure=" + departure + "]";
	}

}
